﻿@model QuanLyGiaoVuUI.Models.GiangVienClient.DangKyKetThucLopMonHocViewModel
@{
    ViewBag.Title = "DangKyKetThucLopMonHoc";
    Layout = "~/Views/Shared/_LayoutGiangVienClient.cshtml";
}


<h2>ĐĂNG KÝ THỜI GIAN KẾT THÚC MÔN</h2>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function () {

        // initialise the "Select date" link
        $('#date-pick')
            .datePicker(
                // associate the link with a date picker
                {
                    createButton: false,
                    startDate: '01/01/2005',
                    endDate: '31/12/2020'
                }
            ).bind(
                // when the link is clicked display the date picker
                'click',
                function () {
                    //updateSelects($(this).dpGetSelected()[0]);
                    $(this).dpDisplay();
                    return false;
                }
            ).bind(
                // when a date is selected update the SELECTs
                'dateSelected',
                function (e, selectedDate, $td, state) {
                    updateSelects(selectedDate);
                }
            ).bind(
                'dpClosed',
                function (e, selected) {
                    updateSelects(selected[0]);
                }
            );

        var updateSelects = function (selectedDate) {
            var selectedDate = new Date(selectedDate);
            var date = selectedDate.getDate();
            var month = selectedDate.getMonth() + 1;

            var year = selectedDate.getFullYear();
            $('#ngayketthuc').val(month + "/" + date + "/" + year);
        }


        // default the position of the selects to today
        var today = new Date();
        updateSelects(today.getTime());

        // and update the datePicker to reflect it...
        $('#d').trigger('change');
    });
</script>

@if (Model != null)
{
    if (Model.DanhSachLopMonHoc != null)
    {
        <table style="padding: 10px;width: 500px;margin: 0 auto;">
        <tr>
            <td>@Html.DropDownList("chonlopmonhoc", new SelectList(Model.DanhSachLopMonHoc, "MaLopMonHoc", "MaLopVaTenMonHoc"))</td>
            <td><input type="text" id="ngayketthuc" value="" />
                <a id="date-pick" class="dp-applied"><img src="../../content/themes/admin/images/forms/icon_calendar.jpg" alt=""></a>
            </td>            
        </tr>
            <tr>
                <td><input type="button" id="dangkyketthuclmh" value="Đăng Ký" /></td>
            </tr>
        </table>
    }
}
<div>
    <div id="thongtindangky">
    </div>
</div>
<script>
    $(document).ready(function () {
        $('#dangkyketthuclmh').click(function () {
            var malopmonhoc = $("#chonlopmonhoc").val();
            var ngayketthuc = $('#ngayketthuc').val();
            $.post("/GiangVienClient/DangKyKetThucLopMonHoc", { malopmonhoc: malopmonhoc, ngayketthuc: ngayketthuc }, function (data) {                
                alert(data.message);
                if (data.success == true) {
                    window.location = "/GiangVienClient/DangKyKetThucLopMonHoc";
                }
            });
        });
        $('#thongtindangky').load("/GiangVienClient/LayThongTinDangKyKetThucLopMonHoc");
    });
</script>


